package cn.yunhe.test;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.SecureCacheResponse;
import java.net.Socket;
import java.util.Scanner;

public class ClientWrite  extends  Thread {
    private Socket socket=null;
    public  ClientWrite (Socket socket){
        this.socket=socket;
    }
    public  void  run(){
        try {
            Scanner scanner=new Scanner(System.in);
            BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
            int num= (int) (Math.random()*100);
            while (true){
                String str=scanner.next();
                if(str!=null&&!"".equals(str)){
                    bw.write("用户"+num+"说:   "+str);
                    bw.newLine();
                    bw.flush();
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
